package com.qiangesoft.weather.gaode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiangesoft.weather.gaode.entity.Weather;
import com.qiangesoft.weather.gaode.mapper.WeatherMapper;
import com.qiangesoft.weather.gaode.service.IWeatherService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 实时天气 服务实现类
 * </p>
 *
 * @author qiangesoft
 * @since 2023-08-10
 */
@Service
public class WeatherServiceImpl extends ServiceImpl<WeatherMapper, Weather> implements IWeatherService {

    @Override
    public Weather liveWeather(String adcode) {
        LambdaQueryWrapper<Weather> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Weather::getAdcode, adcode)
                .last("limit 1")
                .orderByDesc(Weather::getId);
        return baseMapper.selectOne(queryWrapper);
    }
}
